/*
Copyright (C) 1996-1997 Id Software, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/
// cvar.h

#pragma once

// written to config.cfg
#define CVAR_ARCHIVE		1

// changes are broadcast to all clients
#define CVAR_SERVER			2

// if this cvar has it's value changed then directq needs to be restarted
#define CVAR_RESTART		4

// if this cvar is changed then the renderer must be restarted
#define CVAR_RENDERER		8

// if this cvar is changed then the map must be reloaded
#define CVAR_MAP			16

// marked for archiving via a "seta" command
#define CVAR_SETA			32

struct cvar_t
{
public:
	char	*name;
	char	*string;
	int		flags;
	float	value;
	int		integer;
	BOOL	boolean;
	BOOL	recursive;

	xcommand_t callback;
};


// equivelant to "<name> <variable>" typed at the console
void Cvar_Set (cvar_t *var, char *value);
void Cvar_SetValue (cvar_t *var, float value);

// returns 0 if not defined or non numeric
float Cvar_VariableValue (char *var_name);

// returns an empty string if not defined
char *Cvar_VariableString (char *var_name);

// attempts to match a partial variable name for command line completion
// returns NULL if nothing fits
char *Cvar_CompleteVariable (struct key_autotab_t *at, char *partial);

// called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known
// command.  Returns TRUE if the command was a variable reference that
// was handled. (print or change)
BOOL Cvar_Command (cvar_t *v);

// Writes lines containing "set variable value" for all variables
// with the archive flag set to TRUE.
void Cvar_WriteVariables (FILE *f);

// returns an existing cvar or registers a new one, copying off these values to the cvar in both cases
cvar_t *Cvar_Get (char *var_name, char *var_value, int flags = 0, xcommand_t callback = NULL);

cvar_t *Cvar_FindVar (char *var_name);
void Cvar_SetA_f (void);
cvar_t *Cvar_NextServerCvar (char *prev);

